package com.kgc.ljp.OutputStream;

import java.io.*;
public class DataOutDemo {
    public static void main(String[] args)
            throws IOException{
        String file = "data.dat";//项目文件夹
        OutputStream out = new FileOutputStream(file);
        //DataOutputStream 实现基本类型数据的序列化
        //将基本类型数据拆开为byte序列，写入到out流中
        DataOutputStream dos = new DataOutputStream(out);
        dos.write(-2);
        dos.writeInt(-2);
        dos.writeLong(-2);
        dos.writeByte(-2);
        dos.writeDouble(-2);
        dos.writeShort(-2);
        dos.writeFloat(-2);
        dos.writeBoolean(true);
        dos.writeChar('中');
        dos.close();

    }
}
